<template>
  <el-container
    class="layout"
    style="height: 100vh;"
  >
    <el-aside
      width="200px"
      v-show="leftStatus"
    >
      <el-scrollbar>
        <h4 style="text-align:center">
          <span>
            <img
              width="150"
              src="https://element-plus.gitee.io/images/element-plus-logo.svg"
              @click="router.push('/dashboard/index')"
              style="cursor:pointer"
            />
          </span>
        </h4>
        <el-menu
          background-color="#001529"
          text-color="#fff"
          :default-active="defaultActive"
          router
        >
          <el-menu-item index="/dashboard/index">
            <template #title>
              <el-icon>
                <message />
              </el-icon>欢迎界面
            </template>
          </el-menu-item>
          <el-sub-menu index="2">
            <template #title>
              <el-icon>
                <icon-menu />
              </el-icon>用户管理
            </template>
            <el-menu-item index="/dashboard/user">用户列表</el-menu-item>
          </el-sub-menu>
          <el-sub-menu index="3">
            <template #title>
              <el-icon>
                <Film />
              </el-icon>电影管理
            </template>
            <el-menu-item index="/dashboard/film">电影列表</el-menu-item>
          </el-sub-menu>
          <el-sub-menu index="4">
            <template #title>
              <el-icon>
                <VideoCamera />
              </el-icon>影院管理
            </template>
            <el-menu-item index="/dashboard/cinema">影院列表</el-menu-item>
          </el-sub-menu>
        </el-menu>
      </el-scrollbar>
    </el-aside>

    <el-container>
      <el-header style="font-size: 12px">
        <div class="toolbar">
          <div @click="leftStatus = !leftStatus">
            <el-icon :size="26">
              <Expand />
            </el-icon>
          </div>
          <!-- <el-dropdown>
            <el-icon style="margin-right: 8px; margin-top: 1px">
              <setting />
            </el-icon>
            <template #dropdown>
              <el-dropdown-menu>
                <el-dropdown-item>View</el-dropdown-item>
                <el-dropdown-item>Add</el-dropdown-item>
                <el-dropdown-item>Delete</el-dropdown-item>
              </el-dropdown-menu>
            </template>
          </el-dropdown>
          <span>Tom</span> -->
        </div>
      </el-header>

      <el-main>
        <el-scrollbar>
          <router-view></router-view>
        </el-scrollbar>
      </el-main>
      <el-footer>版权信息&copy;太原HTML Create By 2022</el-footer>
    </el-container>
  </el-container>
</template>

<script lang="ts" setup>
import {
  Menu as IconMenu,
  Message,
  Setting,
  Film,
  VideoCamera,
  Expand
} from '@element-plus/icons-vue'
import { onMounted, ref } from 'vue'
import { useRoute,useRouter } from 'vue-router'
let leftStatus = ref(true)
let defaultActive = ref('/dashboard/index')
const route = useRoute()
const router =  useRouter()
onMounted(() => {
  console.log(route.path)
  defaultActive.value = route.path
})
</script>

<style scoped lang="scss">
.layout .el-header {
  position: relative;
}

.layout .el-aside {
  color: #fff;
  background: #001529;
}

.layout .el-menu {
  border-right: none;
}

.layout .el-main {
  background-color: #f0f2f5;
}

.layout .el-footer {
  /* background-color: #f0f2f5; */
  /* text-align: center; */
  display: flex;
  justify-content: center;
  align-items: center;
}

.layout .toolbar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  right: 20px;
}
</style>
